#include <iostream>
#include <fstream>
#include <vector>
#include <pthread.h>
#include <stdlib.h>//srand(),rand()
#include <sys/time.h>

using namespace std;

const int N = 1000;
//const int N = 100000000;//10亿

int main ()
{
	timeval starttime,endtime;
	long int timeuse;
	vector<int> buf;
	gettimeofday(&starttime,0);
	///*
	for ( int i = 0; i < N; i++ )
	{
		buf.push_back(i);
	}
	//*/
	gettimeofday(&endtime,0);
	timeuse = 1000000*(endtime.tv_sec - starttime.tv_sec) + endtime.tv_usec - starttime.tv_usec;
	cout << timeuse << " us" << endl;
	
	fstream tmpfile ("tmp.data", ios::out /*| ios::app*/ );
	gettimeofday(&starttime,0);
	///*
	for ( int i = 0; i < N; i++ )
	{
		tmpfile << i << endl;
	}
	//*/
	gettimeofday(&endtime,0);
	timeuse = 1000000*(endtime.tv_sec - starttime.tv_sec) + endtime.tv_usec - starttime.tv_usec;
	cout << timeuse << " us" << endl;
	string a;
	a = string(2);
	cout << a << endl;
	return 0;
}
/*
数据量	磁盘用时	内存用时	倍数
64	175 us		87 us		2.0
128	326 us		91 us		3.6
256	617 us		96 us		6.4
512	1306 us		105 us		12.4
1024	2440 us		120 us		20.3
1W	17195 us	376 us		45.7
10W	144013 us	2857 us		50.4
100W	1440933 us	23908 us	60.3
1000W	13965178 us	198128 us	70.5
*/
